import math
def lcm(a, b):
    lcm = (a * b) // math.gcd(a, b)
    return lcm

dp = [float('inf')] * 2022  # dp[i]代表从1到i的最短路径
dp[1] = 0
for i in range(1, 2022):
    for j in range(i+1, i+22):
        if j > 2021:
            break
        dp[j] = min(dp[j], dp[i] + lcm(i, j))

print(dp[2021])
